% Function implementing equality constraints
function [x,y] = cloth_eqconstr2(array)

% Convert array to 3d tensor
tensor = array2tensor(array);
N=length(tensor(:,1,1));
hulpmatrix = zeros(4,3);

% Every point has a penalty for the distance from the desired coordinates
punt=squeeze(tensor(1,1,:));
hulpmatrix(1,:)=punt'-[-N/2+3.5 -N/2+3.5 3.2];
% punt=squeeze(tensor(N,1,:));
% hulpmatrix(2,:)=punt'-[-N/2 N/2 1];
% punt=squeeze(tensor(1,N,:));
% hulpmatrix(3,:)=punt'-[N/2 -N/2 1];
% punt=squeeze(tensor(N,N,:));
% hulpmatrix(4,:)=punt'-[N/2 N/2 1];

y = reshape(hulpmatrix,[],1);
x=[];

%% Globe constraint
norm=sum(tensor.^2,3).^.5;
x=reshape(2-norm,[],1);

